<?php

use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
use Jialeo\LaravelSchemaExtend\Schema;

class CreateOrdersTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        if (!Schema::hasTable('c_orders')) {
            Schema::create('c_orders', function (Blueprint $table) {
                $table->increments('id')->comment('ID');
                $table->string('sn', 50)->comment('订单号');
                $table->integer('user_id')->default(0)->comment('用户ID');
                $table->integer('address_id')->default(0)->comment('收货地址ID');
//            $table->integer('goods_id')->default(0)->comment('商品ID');
                $table->integer('nums')->comment('商品数');
                $table->decimal('order_price')->comment('订单价格');
                $table->decimal('pay_price')->comment('支付价格');
                $table->decimal('total_price')->comment('订单总价格');
                $table->decimal('logis_price')->comment('物流费用');
                $table->tinyInteger('pay_type')->default(0)->comment('支付方式(1:微信,2:支付宝,3:余额,4:代付)');
                $table->tinyInteger('order_type')->default(0)->comment('商品类型(1:课程,2:商品)');
                $table->timestamp('pay_time')->default(null)->nullable()->comment('支付时间');
                $table->tinyInteger('pay_status')->default(0)->comment('是否支付(1:已支付,0:未支付)');
                $table->tinyInteger('order_status')->default(0)->comment('订单状态(0:未完成,1:已完成)');
                $table->tinyInteger('delivery_status')->default(0)->comment('发货状态(0:未发货,1:已发货)');
                $table->timestamp('delivery_time')->default(null)->comment('发货时间');
                $table->tinyInteger('receive_status')->default(0)->comment('收货状态(0:未收货,1:已收货)');
                $table->timestamp('receive_time')->default(null)->comment('收货时间');
                $table->string('remarks', 255)->comment('备注');
                $table->timestamps();
                $table->comment = '订单表';
            });
        }
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('c_orders');
    }
}
